package tomcat.Impl;

import tomcat.Cookie;

public class CookieImpl implements Cookie {

    private  String domain;
    private String name;
    private String value;
    private String path;
    private Integer maxAge;

    public CookieImpl(String name, String value) {
        this.name = name;
        this.value = value;
    }

    @Override
    public void setDomain(String pattern) {
        this.domain = pattern;
    }

    @Override
    public void setMaxAge(int expiry) {
        this.maxAge = expiry;
    }

    @Override
    public void setPath(String uri) {
        this.path = uri;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        // c=xxx; Max-Age=9999; path=xxxx; domain=
        String ret = name + "=" + value;
        if (maxAge!=null){
            ret += "; Max-Age=" + maxAge;
        }
        if (path!=null){
            ret += "; path" + path;
        }
        if (domain!=null){
            ret += "; domain" + domain;
        }
        return ret;
    }
}
